package com.cvv.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;


import com.cvv.dao.StationMapper;
import com.sun.org.apache.xpath.internal.operations.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cvv.dao.OrderMapper;
import com.cvv.entity.Order;

@Controller
@RequestMapping("orderapi")
public class OrderController {

	@Autowired
	private OrderMapper ordermapper;
	@Autowired
	private StationMapper stationMapper;
	@RequestMapping("getallorder")
	public String getallorder(ModelMap mp){
		List<Order> list = ordermapper.getallorder();
		mp.addAttribute("listorder", list);
		return "forward:../sch_hub/order/orderList.jsp";
	}

	@RequestMapping(value = "update",method = RequestMethod.POST)
	@ResponseBody
	public String update(String station,String orderId){
		Order order=new Order();
		order.setOrderId(Integer.parseInt(orderId));
		order.setStation(stationMapper.selectByStationName(station));
		if(ordermapper.updateByPrimaryKeySelective(order)>=1)
		return "修改成功！";
		else
			return "修改失败";
	}
}
